﻿import React from 'react';
import { Link } from 'react-router';
import { Row, Col, Button, Form, } from 'antd';

const createForm = Form.create;
const FormItem = Form.Item;

function noop() {
  return false;
}

//自动登录选框
function onChange(e) {
  console.log(`checked = ${e.target.checked}`);
}


let Login = React.createClass({

  contextTypes: {
    router: React.PropTypes.object
  },

  getInitialState() {
    return {
     /* spanTxt: '还没账号？',
      btnTxt: '马上注册',*/
    }
  },

  getDefaultProps: function () {
    return {
      value: '',
      name: '',
      onChange: function () {
      },
      placeholder: ''
    }
  },


  handleRouter() {
    let path = this.props.location.pathname;
    let signUp = '/register';
    let signIn = '/login';
    let goPath = ( path == signIn || path == '/') ? signUp : '' ;
    console.log(path)
    this.context.router.push(goPath);
  },


  render () {
    let path = this.props.location.pathname;
    let lastPath = path.split('/')[path.split('/').length - 1];
    console.log(lastPath);
 /*   let spanTxt = ( lastPath == 'login') ? '还没账号？' : '';*/
    let txtName = ( lastPath == 'login'|| lastPath == '') ? '申请入驻' : '填写资料信息';
    return (
      <div className="container">
        <div className="wrap">
          <div className="wrap-img"></div>
        </div>
        <div className="logo">
          <i className="logo-img"></i>
        </div>
        <div className="sign" id="sign">
          <div className="sign-up">
            <Link to="/">返回爱租派首页</Link>
            {/* <label>{spanTxt}</label>*/}
            <Button
              onClick={this.handleRouter}>{txtName}
            </Button>
          </div>
        </div>
        {this.props.children}
      </div>
    );
  }
});


Login = createForm()(Login);
export default Login;
